package cn.jhc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class H2Demo {
    private static final String CREATE_TABLE_SQL = "CREATE TABLE IF NOT EXISTS USERS (" +
            "ID INT auto_increment PRIMARY KEY," +
            "NAME VARCHAR(20)," +
            "AGE INT)";
    
    public static void main(String[] args) {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
            Statement statement = connection.createStatement();
            statement.execute(CREATE_TABLE_SQL);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                connection.close();
            } catch (SQLException ex) {
                throw new RuntimeException(ex);
            }
        }

    }
}
